const axios = require("axios");
const getWeather = () => {
  return new Promise((resolve, reject) => {
    axios
      .get(
        'https://yiketianqi.com/api?unescape=1&version=v6&appid=63192343&appsecret="jZlPVGP6"&cityid=101282001'
      )
      .then((res) => {
        // console.log(res.data);
        const { date, week, tem1, tem2, wea, air_tips } = res.data;
        const strArry = date.split("-");
        const time = `今天是${strArry[0]}年${strArry[1]}月${strArry[2]}日 ${week}`;
        resolve({
          time,
          tem1,
          tem2,
          wea,
          air_tips,
        });
      })
      .catch((err) => {
        reject(err);
      });
  });
};
module.exports = getWeather;
